<?php if (!defined('THINK_PATH')) exit(); /*a:6:{s:43:"./application/admin/view/content\index.html";i:1494375953;s:47:"./application/admin/view/public\public_css.html";i:1494375954;s:47:"./application/admin/view/public\header-min.html";i:1494376891;s:41:"./application/admin/view/public\left.html";i:1494375954;s:43:"./application/admin/view/public\footer.html";i:1494376909;s:46:"./application/admin/view/public\public_js.html";i:1495076811;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>企业内容管理系统</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet" href="__PUBLIC__/bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://cdn.bootcss.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="__PUBLIC__/dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
     folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="__PUBLIC__/dist/css/skins/_all-skins.min.css">

<link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
<link rel="stylesheet" href="__PUBLIC__/static/css/style.css">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <header class="main-header">
    <!-- Logo -->
    <a href="<?php echo U('admin/index'); ?>" class="logo">
        <!-- mini logo for sidebar mini 50x50 pixels -->
        <span class="logo-mini">CK</span>
        <!-- logo for regular state and mobile devices -->
        <span class="logo-lg">CK开源博客</span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
        </a>

        <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">
                <li class="dropdown user user-menu">
                    <a href="#" ><span class="hidden-xs">欢迎你，<?php echo session('user_name'); ?></span></a>
                </li>
                <li class="dropdown user user-menu">
                    <a target="_blank" href="<?php echo U('Home/Index/index'); ?>" >
                        <span class="hidden-xs">前台首页</span>
                    </a>
                </li>
                <li class="dropdown user user-menu">
                    <a href="<?php echo U('Admin/loginOut'); ?>" >
                        <span class="hidden-xs">安全退出</span>
                    </a>
                </li>
                <!-- Control Sidebar Toggle Button -->
            </ul>
        </div>
    </nav>
</header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
        <ul class="sidebar-menu">
                <li class="header">内容管理系统</li>
            <?php if(is_array($initMenu) || $initMenu instanceof \think\Collection || $initMenu instanceof \think\Paginator): $i = 0; $__LIST__ = $initMenu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vm): $mod = ($i % 2 );++$i;if($vm['menu_level'] == 1): ?>
                        <li class=" <?php if($vm['menu_con'] == CONTROLLER_NAME): ?>active<?php endif; ?> treeview">
                            <a href="#">
                                <i class="<?php echo $vm['menu_inc']; ?>"></i> <span><?php echo $vm['menu_name']; ?></span>
                                <span class="pull-right-container">
                                  <i class="fa fa-angle-left pull-right"></i>
                               </span>
                            </a>
                            <ul class="treeview-menu">
                                <?php if(is_array($initMenu) || $initMenu instanceof \think\Collection || $initMenu instanceof \think\Paginator): $i = 0; $__LIST__ = $initMenu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vmm): $mod = ($i % 2 );++$i;if($vmm['menu_level'] == 2 && $vm['menu_id'] == $vmm['parent_id']): ?>
                                        <li class="<?php if(strtolower($vmm['menu_act']) == ACTION_NAME): ?>active<?php endif; ?>" >
                                            <a href="<?php echo U($vmm['menu_con'] .'/' .$vmm['menu_act']); ?>"><i class="<?php echo $vmm['menu_inc']; ?>"></i><?php echo $vmm['menu_name']; ?></a>
                                        </li>
                                    <?php endif; endforeach; endif; else: echo "" ;endif; ?>
                            </ul>
                        </li>
                <?php endif; endforeach; endif; else: echo "" ;endif; ?>
        </ul>
    </section>
    <!-- /.sidebar -->
</aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                文章管理
                <a href="<?php echo U('Admin/Content/addArticle'); ?>" target="_blank"><button type="button" class="btn btn-primary">添加文章</button></a>
            </h1>
            <div class="select-cat breadcrumb">
                <select id="cat" name="cat" class="form-control">
                    <option value="0" selected>全部</option>
                    <?php if(is_array($catList) || $catList instanceof \think\Collection || $catList instanceof \think\Paginator): $i = 0; $__LIST__ = $catList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                        <option value="<?php echo $vo['cat_id']; ?>" <?php if($cat_id == $vo['cat_id']): ?>selected<?php endif; ?>><?php echo $vo['_name']; ?></option>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                  </select>
            </div>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>首页</a></li>
                <li class="active">内容管理</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <!-- Small boxes (Stat box) -->
            <!-- Small boxes (Stat box) -->
            <div class="row">
                <table id="menuList" class="table table-hover">
                    <tr>
                        <th style="text-align:center;">
                          <input id="all" type="checkbox" >
                        </th>
                        <th>排序</th>
                        <th>id</th>
                        <th>标题</th>
                        <th>添加时间</th>
                        <th>分类</th>
                        <th>显示</th>
                        <th>操作</th>
                    </tr>
                    <?php if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                         <tr>
                             <td>
                               <input type="checkbox"  name="id[]" value="<?php echo $vo['id']; ?>">
                             </td>
                             <td>
                                 <input type="text" class="list-order" data-id="<?php echo $vo['id']; ?>" name="list_order" value="<?php echo $vo['list_order']; ?>">
                             </td>
                             <td><?php echo $vo['id']; ?></td>
                             <td><a href="<?php echo U('home/index/show', array('id' => $vo['id'])); ?>" target="_blank"><?php echo $vo['title']; if($vo['po_id'] > 0): ?> <img src="__PUBLIC__/static/images/recommend.png" class="recommend"><?php endif; ?></a></td>
                                 <td><?php echo date('Y-m-d H:i', $vo['add_time']); ?></td>
                                 <td><?php echo get_cat_name($vo['cat_id']); ?></td>
                                 <td class="is-show-td">
                                      <i  data-id="<?php echo $vo['id']; ?>" data-is_show="<?php echo $vo['is_show']; ?>" class="is-show ion-checkmark-circled <?php if($vo['is_show'] == 1): ?>is-show1<?php endif; ?>"></i>
                                 </td>

                                 <td>
                                     <a class="delArticle" href="javascript:void(0);" data-id="<?php echo $vo['id']; ?>" >
                                         <button  type="button" class="btn btn-danger">删除</button>
                                     </a> |
                                     <a class="editArticle"  target="_black" href="<?php echo U('Content/editArticle?', 'id=' .$vo['id']); ?>">
                                         <button type="button" class="btn btn-info">修改</button>
                                     </a>
                                 </td>
                         </tr>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                </table>

                <div>
                    <button type="button" class="btn btn-danger delArticle" >删除</button>
                    <button id="listOrder"  type="button" class="btn btn-info" >排序</button>
                </div>
                 <div>
                     <?php echo $list->render(); ?>
                 </div>
            </div>


        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <footer class="main-footer">
    <div class="pull-right hidden-xs">
        <b>Version</b> 1.0.0
    </div>
    <strong>Copyright &copy; 2017-2027 <a href="#">CK开源博客</a></strong>
</footer>

    <!-- Control Sidebar -->

    <!-- /.control-sidebar -->
    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- jQuery 2.2.3 -->
<script src="__PUBLIC__/jquery/jquery-2.1.4.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="__PUBLIC__/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.6 -->
<script src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/jquery-json/src/jquery.json.js"></script>
<script src="__PUBLIC__/dist/js/app.min.js"></script>
<script src="__PUBLIC__/layer/layer.js" charset="utf-8"></script>
<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__PUBLIC__/UEditor/ueditor.config.js"></script>
<script src="__PUBLIC__/UEditor/ueditor.all.min.js"></script>

<script>

         //删除文章
    $('.delArticle').click(function(){

          //多选删除
         var checkId = [];
         ($('input[type=checkbox]:checked')).each(function(){
             checkId.push($(this).val());
         });
             //单个删除
        var id = $(this).data('id');
        layer.open({
            btn: ['删除', '取消'],
            yes: function(){
                   //如果是多选
                if(checkId.length > 0){
                     id = checkId;
                }
                    $.ajax({
                        type: 'POST', //GET,POST
                        url: '<?php echo WEB_PATH; ?>/Admin/Content/delArticle?id=' + id,
                        dataType: 'json', //xml,json,script，默认为null
                        success: function (data) {
                            layer.open({
                                type: 1,
                                time: 5000,
                                area: ['200px', '200px'],
                                content: data.msg //服务器返回的消息
                            });
                            setTimeout(function () {
                                window.location.reload();
                            }, 1200);
                        },
                        error: function (event, errorText, errorType) { //错误时调用
                            alert(errorText + errorType);
                        }
                    })

            },
            no: function(){

            },
            fixed: false, //不固定
            maxmin: true,
            content:'确定要删除吗？'
        });
    });

         //全选，全不选
         $('#all').click(function(){
             if(this.checked){
                 $('input[type=checkbox]').prop("checked", true);
             }else{
                 $('input[type=checkbox]').prop("checked", false);
             }
         });
         //排序
         var  list_order = [];
         $("input[name='list_order']").change(function(){
             list_order[$(this).data('id')] = $(this).val();
         });
         $('#listOrder').click(function(){
             list_order = $.toJSON(list_order); //格式化JS数组，将其转化为JSON格式发送到服务
             $.ajax({
                 type: 'POST', //GET,POST
                 url: '<?php echo WEB_PATH; ?>/Admin/Content/orderArticle',
                 data:{list_order:list_order},
                 dataType: 'json', //xml,json,script，默认为null
                 success: function (data) {
                     layer.open({
                         type: 1,
                         time: 5000,
                         area: ['200px', '200px'],
                         content: data.msg //服务器返回的消息
                     });
                     setTimeout(function () {
                         window.location.reload();
                     }, 1200);
                 },
                 error: function (event, errorText, errorType) { //错误时调用
                     alert(errorText + errorType);
                 }
             })
         });
         //显示与不显示
         $('.is-show').click(function(){
             var id = $(this).data('id');
             var is_show = $(this).data('is_show');
             var isShow = $(this);
             $.ajax({
                 type: 'POST',
                 url:"<?php echo WEB_PATH; ?>/Admin/Content/isShowArticle?id=" + id + "&is_show=" + is_show,
                 dataType:'json',
                 success:function(data){
                     if(data.status){
                         if(isShow.hasClass("is-show1")){
                             isShow.removeClass("is-show1");
                             isShow.data('is_show', 0);
                         }else{
                             isShow.addClass("is-show1");
                             isShow.data('is_show', 1);
                         }
                     }
                 }

             });
         });

         //根据分类查看文章
     $("#cat").change(function(){
         $cat_id = $(this).val();
         window.location.href="<?php echo WEB_PATH; ?>/Admin/Content/index?cat_id=" + $cat_id;
     });

</script>
</body>
</html>
